/*
 * ClientConnection.hpp
 *
 *  Created on: 15 mei 2013
 *      Author: maarten
 */

#ifndef CLIENTCONNECTION_HPP_
#define CLIENTCONNECTION_HPP_

#include "CommandCodes.hpp"
#include "Message.hpp"

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <sys/socket.h>
#include <unistd.h>

#include <pwd.h>
#include <shadow.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>

#include <vector>

class ClientConnection {
public:
	ClientConnection(int sd, struct sockaddr con);
	virtual ~ClientConnection();

	void checkUserPass();

	Message revcMessage();
	bool sendMessage(Message aMessage);

	void setUsername(std::string anUsername);
	std::string getUsername();
	void setPassword(std::string aPassword);
	std::string getPassword();
	bool getWrite();
	void setWrite();
	bool getLogon();
	void setLogon(bool aLogon);

private:
	void* get_in_addr(struct sockaddr *sa);

	int socketDescriptor;
	struct sockaddr connectie;
	std::string username;
	std::string password;
	char filePart[FILESPLIT];
	bool writePermissions;
	bool logon;
};

#endif /* CLIENTCONNECTION_HPP_ */
